package com.sgb.kjwl.view.ui.activity.material;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.blankj.utilcode.util.ColorUtils;
import com.gyf.barlibrary.ImmersionBar;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.sgb.alimaplibrary.util.ToastUtil;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityGoodsSearchResultBinding;
import com.sgb.kjwl.di.home.DaggerHomeComponent;
import com.sgb.kjwl.di.home.HomeModule;
import com.sgb.kjwl.model.entity.HomeSearchCompanyEntity;
import com.sgb.kjwl.model.entity.StoreEntity;
import com.sgb.kjwl.model.entity.request.MaterialFilterJson;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.kjwl.model.entity.user.GoodsListEntity;
import com.sgb.kjwl.utils.FileUtils;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.MaterialEvent;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.shop.ShopGoodsDetailActivity;
import com.sgb.kjwl.view.ui.adapter.search.MaterialAdapter;
import com.sgb.kjwl.view.widget.ThreeLevelAreaWindow;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.base.model.entity.SelectPopEntity;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.entity.BaseAreaEntity;
import com.swgk.core.util.MToast;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
 * @author PC
 */
public class GoodsSearchResultActivity extends AppActivity {

    private ActivityGoodsSearchResultBinding binding;
    @Inject
    GoodsSearchResultModle viewModel;
    private String searchContext = "钢材";

    private ThreeLevelAreaWindow mThreeLevelPopWindow;
    private List<String> mAreaId = new ArrayList<>();
    private String mCityId = "";
    private String mProvince = "";
    private String mArea = "";
    private String mProvinceName = "";
    private int testPosition;

    private MaterialAdapter goodsUpAdapter;
    private MaterialAdapter goodsDownAdapter;
    private HomeSearchCompanyUpAdapter companyUpGoodsAdapter;

    private HomeSearchCompanyUpAdapter companyUpAdapter;
    private HomeSearchCompanyAdapter companyDownAdapter;

    /**
     * 是否是自营产品
     */
    private String isZiYingChecked = "";
    /**
     * 是否是促销商品
     * true 促销商品 false 非促销商品
     */
    private String isPromotionalGoods = "";

    private int titleTab = 0;

    public static void start(Context context, String searchContext) {
        Intent intent = new Intent();
        intent.putExtra("searchContext", searchContext);
        intent.setClass(context, GoodsSearchResultActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerHomeComponent.builder().appComponent(appComponent).homeModule(new HomeModule(this)).build().inject(this);
    }

    private void requestGoodsUpData(boolean isLoadMore) {
        if (!isLoadMore) {
            binding.nsvGoods.scrollTo(0, 0);
            binding.refreshLayoutGoods.autoRefresh();
        }
        viewModel.searchByKeywordGoods(searchContext, mProvince, mCityId, mAreaId, isPromotionalGoods, isZiYingChecked, isLoadMore);
    }

    private void requestCompanyUpData(boolean isLoadMore) {
        if (!isLoadMore) {
            binding.nsvCompany.scrollTo(0, 0);
            binding.refreshLayoutCompany.autoRefresh();
        }
        viewModel.searchByKeywordStore(searchContext, isLoadMore);
    }

    @Override
    protected void initView() {
        //使用该属性必须指定状态栏的颜色，不然状态栏透明，很难看
        ImmersionBar.with(this)
                .statusBarColor(R.color.color_main)
                .fitsSystemWindows(true)
                .init();
        binding = DataBindingUtil.setContentView(GoodsSearchResultActivity.this, R.layout.activity_goods_search_result);
        binding.ivBack.setOnClickListener(this);
        binding.tvSearch.setOnClickListener(this);
        binding.companyLayout.setOnClickListener(this);
        binding.goodsLayout.setOnClickListener(this);
        binding.goodsDownLoadMore.setOnClickListener(this);
        binding.companyDownLoadMore.setOnClickListener(this);
        searchContext = getIntent().getStringExtra("searchContext");
        binding.searchContext.setText(searchContext);
        binding.tvSearchDelete.setVisibility(View.VISIBLE);
        binding.setViewModel(viewModel);
        mProvince = viewModel.getAreaCode();
        requestGoodsUpData(false);
        requestCompanyUpData(false);
        viewModel.getGoodsList(false);
        viewModel.getSupplierListModel(false);
        initButton();
        initFilterView();
        viewModel.getAreaData();
        goodsUpAdapter = new MaterialAdapter(this, null, false);
        binding.goodsViewUp.setAdapter(goodsUpAdapter);

        goodsDownAdapter = new MaterialAdapter(this, null, false);
        binding.goodsViewDown.setAdapter(goodsDownAdapter);

        companyUpGoodsAdapter = new HomeSearchCompanyUpAdapter(this, null);
        binding.companyViewUpGoods.setAdapter(companyUpGoodsAdapter);

        companyUpAdapter = new HomeSearchCompanyUpAdapter(this, null);
        binding.companyViewUp.setAdapter(companyUpAdapter);

        companyDownAdapter = new HomeSearchCompanyAdapter(this, null);
        binding.companyViewDowm.setAdapter(companyDownAdapter);

        binding.companyViewUpGoods.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.companyViewDowm.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.companyViewUp.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.goodsViewDown.setLayoutManager(new LinearLayoutManager(getActivity()));
        binding.goodsViewUp.setLayoutManager(new LinearLayoutManager(getActivity()));

        binding.refreshLayoutGoods.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                requestGoodsUpData(true);
            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                requestGoodsUpData(false);
                requestCompanyUpData(false);
            }
        });

        binding.refreshLayoutCompany.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                requestCompanyUpData(true);
            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                requestGoodsUpData(false);
                requestCompanyUpData(false);
            }
        });

        goodsDownAdapter.setOnItemClick(new AdapterOnItemClick<GoodsListEntity>() {
            @Override
            public void onItemClick(GoodsListEntity goodsListEntity, int position) {
                if ("7".equals(goodsListEntity.getId())) {
                    MaterialFilterJson filterJson = new MaterialFilterJson();
                    filterJson.setStrengthId(goodsListEntity.getSort());
                    ConcreteDetailActivity2.start(getActivity(), goodsListEntity.getId(), filterJson);
                } else {
                    ShopGoodsDetailActivity.start(GoodsSearchResultActivity.this, goodsListEntity.getId(), "", goodsListEntity.getSkuid());
                }
            }
        });

        goodsUpAdapter.setOnItemClick(new AdapterOnItemClick<GoodsListEntity>() {
            @Override
            public void onItemClick(GoodsListEntity goodsListEntity, int position) {
                if ("7".equals(goodsListEntity.getId())) {
                    MaterialFilterJson filterJson = new MaterialFilterJson();
                    filterJson.setStrengthId(goodsListEntity.getSort());
                    ConcreteDetailActivity2.start(getActivity(), goodsListEntity.getId(), filterJson);
                } else {
                    ShopGoodsDetailActivity.start(GoodsSearchResultActivity.this, goodsListEntity.getId(), "", goodsListEntity.getSkuid());
                }
            }
        });
        companyUpGoodsAdapter.setOnItemClick(new AdapterOnItemClick<StoreEntity>() {
            @Override
            public void onItemClick(StoreEntity storeEntity, int position) {
                if (TextUtils.isEmpty(storeEntity.getNo())) {
                    ToastUtil.show(getActivity(), "企业店铺No不能为空");
                    return;
                }
                WebsiteInfoActivity.start(GoodsSearchResultActivity.this, storeEntity.getNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY, 0, 0);
            }
        });

        companyUpAdapter.setOnItemClick(new AdapterOnItemClick<StoreEntity>() {
            @Override
            public void onItemClick(StoreEntity storeEntity, int position) {
                if (TextUtils.isEmpty(storeEntity.getNo())) {
                    ToastUtil.show(getActivity(), "企业店铺No不能为空");
                    return;
                }
                WebsiteInfoActivity.start(GoodsSearchResultActivity.this, storeEntity.getNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY, 0, 0);
            }
        });
        companyDownAdapter.setOnItemClick(new AdapterOnItemClick<HomeSearchCompanyEntity>() {
            @Override
            public void onItemClick(HomeSearchCompanyEntity storeEntity, int position) {
                if (TextUtils.isEmpty(storeEntity.getSupplier())) {
                    ToastUtil.show(getActivity(), "企业店铺No不能为空");
                    return;
                }
                WebsiteInfoActivity.start(GoodsSearchResultActivity.this, storeEntity.getSupplier(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY, 0, 0);
            }
        });
        binding.searchContext.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
        binding.searchContext.setOnKeyListener(new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
                    if (TextUtils.isEmpty(binding.searchContext.getText().toString().trim())) {
                        MToast.showToast(GoodsSearchResultActivity.this, "请输入关键字");
                        return true;
                    }
                    closeKeybord();
                    searchContext = binding.searchContext.getText().toString().trim();
                    binding.searchContext.clearFocus();
                    //补充存储方法
                    FileUtils.setJsonTxt(searchContext, GoodsSearchResultActivity.this);
                    requestGoodsUpData(false);
                    requestCompanyUpData(false);
                    viewModel.getGoodsList(false);
                    viewModel.getSupplierListModel(false);
                }
                return false;
            }
        });
        binding.searchContext.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (TextUtils.isEmpty(s)) {
                    binding.tvSearchDelete.setVisibility(View.GONE);
                } else {
                    binding.tvSearchDelete.setVisibility(View.VISIBLE);
                }
            }
        });
        binding.tvSearchDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                binding.searchContext.setText("");
            }
        });
//        binding.rootLayout.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View v, MotionEvent event) {
//                binding.rootLayout.setFocusable(true);
//                binding.rootLayout.setFocusableInTouchMode(true);
//                binding.rootLayout.requestFocus();
//                return false;
//            }
//        });
    }

    private void initButton() {
        SelectPopEntity selectPopEntity1 = new SelectPopEntity("自营", "1", false, false);
        binding.sct.addTextButton(selectPopEntity1);
        SelectPopEntity selectCuXiao = new SelectPopEntity("促销", "2", false, false);
        binding.sct.addTextButton(selectCuXiao);
        SelectPopEntity selectPopEntity2 = new SelectPopEntity("仓储地", "4", false, true);
        binding.sct.addTextButton(selectPopEntity2);
        binding.sct.onSetCallPop((position, content, bg, entity) -> {
            testPosition = position;
            if ("1".equals(entity.getType())) {
                if ("".equals(isZiYingChecked)) {
                    isZiYingChecked = "1";
                } else {
                    isZiYingChecked = "";
                }
                requestGoodsUpData(false);
            } else if ("2".equals(entity.getType())) {
                if ("".equals(isPromotionalGoods)) {
                    isPromotionalGoods = "2";
                } else {
                    isPromotionalGoods = "";
                }
                requestGoodsUpData(false);
            } else if ("4".equals(entity.getType())) {
                binding.sct.contentSelect(false, true, position);
                EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                new Handler().postDelayed(() -> mThreeLevelPopWindow.showPopwindow(binding.sct, 0, 0), 300);
            }
        });
    }

    private void initFilterView() {
        mThreeLevelPopWindow = new ThreeLevelAreaWindow(this) {
            @Override
            protected void provinceClick(BaseAreaEntity baseAreaEntity, int position) {
                if (!mProvince.equals(baseAreaEntity.getId())) {
                    mCityId = "";
                }
                mProvince = baseAreaEntity.getId();
                mArea = baseAreaEntity.getSimpleName();
                if (mAreaId != null) {
                    mAreaId.clear();
                }
            }

            @Override
            protected void cityClick(BaseAreaEntity baseAreaEntity, int position) {
                if (!mCityId.equals(baseAreaEntity.getId())) {
                    if (mAreaId != null) {
                        mAreaId.clear();
                    }
                    mArea = "";
                }
                mCityId = baseAreaEntity.getId();
                mArea = baseAreaEntity.getSimpleName();
            }

            @Override
            protected void areaMoreClick(List list, int position) {
                if (mAreaId != null) {
                    mAreaId.clear();
                }
                mArea = "";
                for (Object o : list) {
                    BaseAreaEntity baseAreaEntity = (BaseAreaEntity) o;
                    if (mAreaId != null && !mAreaId.contains(baseAreaEntity.getId())) {
                        mAreaId.add(baseAreaEntity.getId());
                    }
                    if (!mArea.contains(baseAreaEntity.getSimpleName())) {
                        mArea = baseAreaEntity.getSimpleName();
                    }
                }
            }
        };
        mThreeLevelPopWindow.setShowSimpleName(true);
        mThreeLevelPopWindow.setBgView(binding.grayLayout);
        mThreeLevelPopWindow.setAreaMore();
        mThreeLevelPopWindow.setCitySingle();
        mThreeLevelPopWindow.setProvinceSingle();
        mThreeLevelPopWindow.setOnResultClick((key1, key2, key3) -> {
            mProvinceName = mProvince;
            requestGoodsUpData(false);
        });
        mThreeLevelPopWindow.setOnDisMissClick(() -> {
            if ("".equals(mProvinceName) || "不限".equals(mProvinceName)) {
                binding.sct.contentSelect(false, false, testPosition);
            } else {
                binding.sct.contentSelect(true, false, testPosition);
            }
        });
    }

    public void setAddressData(List<AddressEntity<List<AddressEntity<List<AddressEntity>>>>> data, String areaCode) {
        mThreeLevelPopWindow.setData(data, true, areaCode);
    }

    public void showGoodsUpList(List<GoodsListEntity> data, boolean isLoadMore, int totalRow, boolean isSuccess) {
        if (isLoadMore) {
            binding.refreshLayoutGoods.finishLoadMore(isSuccess);
            if (data == null || data.size() < 10) {
                binding.refreshLayoutGoods.finishLoadMoreWithNoMoreData();
            }
            goodsUpAdapter.addDatas(data);
        } else {
            binding.goodsView.setText("商品(" + totalRow + ")");
            binding.refreshLayoutGoods.finishRefresh(1000, isSuccess, false);
            if (data == null || data.size() == 0) {
                binding.refreshLayoutGoods.setEnableLoadMore(false);
                binding.blankViewGoods.setVisibility(View.VISIBLE);
                binding.goodsViewUp.setVisibility(View.GONE);
                binding.goodsViewUpLine.setVisibility(View.VISIBLE);
                binding.llGoodsViewDown.setVisibility(View.VISIBLE);
            } else if (data.size() < 10) {
                binding.refreshLayoutGoods.setEnableLoadMore(false);
                binding.blankViewGoods.setVisibility(View.GONE);
                binding.goodsViewUp.setVisibility(View.VISIBLE);
                binding.goodsViewUpLine.setVisibility(View.VISIBLE);
                binding.llGoodsViewDown.setVisibility(View.VISIBLE);
            } else {
                binding.refreshLayoutGoods.setEnableLoadMore(true);
                binding.blankViewGoods.setVisibility(View.GONE);
                binding.goodsViewUp.setVisibility(View.VISIBLE);
                binding.goodsViewUpLine.setVisibility(View.VISIBLE);
                binding.llGoodsViewDown.setVisibility(View.GONE);
            }
            if (binding.companyViewUpGoods.getVisibility() == View.VISIBLE) {
                binding.goodsViewUpLine.setVisibility(View.GONE);
            }
            goodsUpAdapter.setDatas(data);
        }
    }

    public void showCompanyUpList(List<StoreEntity> data, boolean isLoadMore, int totalRow, boolean isSuccess) {
        if (isLoadMore) {
            binding.refreshLayoutCompany.finishLoadMore(isSuccess);
            if (data == null || data.size() < 10) {
                binding.refreshLayoutCompany.finishLoadMoreWithNoMoreData();
            }
            companyUpAdapter.addDatas(data);
        } else {
            binding.companyView.setText("企业(" + totalRow + ")");
            binding.refreshLayoutCompany.finishRefresh(1000, isSuccess, false);
            companyUpAdapter.setDatas(data);
            if (data == null || data.size() == 0) {
                binding.refreshLayoutCompany.setEnableLoadMore(false);
                binding.blankViewCompany.setVisibility(View.VISIBLE);
                binding.companyViewUp.setVisibility(View.GONE);
                binding.companyViewUpGoods.setVisibility(View.GONE);
                binding.llCompanyViewDowm.setVisibility(View.VISIBLE);
            } else if (data.size() == 1) {
                binding.refreshLayoutCompany.setEnableLoadMore(false);
                binding.blankViewCompany.setVisibility(View.GONE);
                binding.companyViewUp.setVisibility(View.VISIBLE);
                binding.companyViewUpGoods.setVisibility(View.VISIBLE);
                binding.llCompanyViewDowm.setVisibility(View.VISIBLE);
                binding.goodsViewUpLine.setVisibility(View.GONE);
                companyUpGoodsAdapter.setDatas(data);
            } else if (data.size() > 1 && data.size() < 10) {
                binding.refreshLayoutCompany.setEnableLoadMore(false);
                binding.blankViewCompany.setVisibility(View.GONE);
                binding.companyViewUp.setVisibility(View.VISIBLE);
                binding.companyViewUpGoods.setVisibility(View.GONE);
                binding.llCompanyViewDowm.setVisibility(View.VISIBLE);
            } else {
                binding.refreshLayoutCompany.setEnableLoadMore(true);
                binding.blankViewCompany.setVisibility(View.GONE);
                binding.companyViewUpGoods.setVisibility(View.GONE);
                binding.companyViewUp.setVisibility(View.VISIBLE);
                binding.llCompanyViewDowm.setVisibility(View.GONE);
            }
        }
    }

    public void showGoodsDownList(List<GoodsListEntity> data, boolean isLoadMore) {
        if (isLoadMore) {
            if (data == null || data.size() == 0) {
                binding.goodsDownLoadMore.setVisibility(View.GONE);
            } else if (data.size() < 10) {
                binding.goodsDownLoadMore.setVisibility(View.GONE);
                goodsDownAdapter.setDatas(data);
            } else {
                binding.goodsDownLoadMore.setVisibility(View.VISIBLE);
                goodsDownAdapter.setDatas(data);
            }
        } else {
            goodsDownAdapter.setDatas(data);
            if (data == null || data.size() == 0) {
                binding.goodsViewDown.setVisibility(View.GONE);
            } else if (data.size() < 10) {
                binding.goodsViewDown.setVisibility(View.VISIBLE);
                binding.goodsDownLoadMore.setVisibility(View.GONE);
            } else {
                binding.goodsViewDown.setVisibility(View.VISIBLE);
                binding.goodsDownLoadMore.setVisibility(View.VISIBLE);
            }

        }
    }

    public void showCompanyDownList(List<HomeSearchCompanyEntity> data, boolean isLoadMore) {
        if (isLoadMore) {
            if (data == null || data.size() == 0) {
                binding.companyDownLoadMore.setVisibility(View.GONE);
            } else if (data.size() < 10) {
                binding.companyDownLoadMore.setVisibility(View.GONE);
                companyDownAdapter.setDatas(data);
            } else {
                binding.companyDownLoadMore.setVisibility(View.VISIBLE);
                companyDownAdapter.setDatas(data);
            }
        } else {
            companyDownAdapter.setDatas(data);
            if (data == null || data.size() == 0) {
                binding.companyViewDowm.setVisibility(View.GONE);
            } else if (data.size() < 10) {
                binding.companyViewDowm.setVisibility(View.VISIBLE);
                binding.companyDownLoadMore.setVisibility(View.GONE);
            } else {
                binding.companyViewDowm.setVisibility(View.VISIBLE);
                binding.companyDownLoadMore.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_search:
                if (TextUtils.isEmpty(binding.searchContext.getText().toString().trim())) {
                    MToast.showToast(GoodsSearchResultActivity.this, "请输入关键字");
                } else {

                    closeKeybord();
                    searchContext = binding.searchContext.getText().toString().trim();
                    binding.searchContext.clearFocus();
                    //补充存储方法
                    FileUtils.setJsonTxt(searchContext, GoodsSearchResultActivity.this);
                    requestGoodsUpData(false);
                    requestCompanyUpData(false);
                    viewModel.getGoodsList(false);
                    viewModel.getSupplierListModel(false);
                }
                break;
            case R.id.goods_layout:
                if (0 == titleTab) {
                    return;
                } else {
                    titleTab = 0;
                }
                binding.refreshLayoutGoods.setVisibility(View.VISIBLE);
                binding.refreshLayoutCompany.setVisibility(View.GONE);
                binding.goodsView.setTextColor(ColorUtils.getColor(R.color.color_main));
                binding.companyView.setTextColor(ColorUtils.getColor(R.color.color_666666));
                binding.goodsLine.setBackgroundColor(ColorUtils.getColor(R.color.color_main));
                binding.companyLine.setBackgroundColor(ColorUtils.getColor(R.color.white));
                binding.sct.setVisibility(View.VISIBLE);
                break;
            case R.id.company_layout:
                if (1 == titleTab) {
                    return;
                } else {
                    titleTab = 1;
                }
                binding.refreshLayoutGoods.setVisibility(View.GONE);
                binding.refreshLayoutCompany.setVisibility(View.VISIBLE);
                binding.goodsView.setTextColor(ColorUtils.getColor(R.color.color_666666));
                binding.companyView.setTextColor(ColorUtils.getColor(R.color.color_main));
                binding.goodsLine.setBackgroundColor(ColorUtils.getColor(R.color.white));
                binding.companyLine.setBackgroundColor(ColorUtils.getColor(R.color.color_main));
                binding.sct.setVisibility(View.GONE);
                break;
            case R.id.goods_down_load_more:
                viewModel.getGoodsList(true);
                break;
            case R.id.company_down_load_more:
                viewModel.getSupplierListModel(true);
                break;

            default:
                break;
        }
    }
}
